window.addEventListener("scroll",changed);

function changed(){
    var scrollTop = document.documentElement.scrollTop;
    if (scrollTop >=90 ){
        document.body.getElementsByTagName("h2")[0].style.fontSize= "50px"; 
    }
    else {
        document.body.getElementsByTagName("h2")[0].style.fontSize= "0"; 
    }
    if (scrollTop>=105)
    {
        document.getElementById("idp1").style.fontSize = "small";
    }
    else {
        document.getElementById("idp1").style.fontSize = "0";
    }
    if(scrollTop>=500)
    {
        for(var i = 0;i<8;i++)
        {
            document.getElementsByClassName("show")[i].style.height = "258px";
        }
    }
    else{
        for(var i = 0;i<8;i++)
            {
                document.getElementsByClassName("show")[i].style.height = "0";
            }
    }
    //文字 与 图片 idtext1 aboutimg
    if(scrollTop>=1000){
        document.getElementById("idtext1").style.transform = "none";
        document.getElementById("aboutimg").style.transform = "scale(1)";
    }
    else{
        document.getElementById("idtext1").style.transform = "translate(-1000px)";
        document.getElementById("aboutimg").style.transform = "scale(0)";
    }
    // 棕色部分
    if(scrollTop>=1400){
        document.body.getElementsByClassName("middle1")[0].style.transform = "scale(1)";
    }
    else{
        document.body.getElementsByClassName("middle1")[0].style.transform = "scale(0)";
    }
    // 我们仨
    if(scrollTop>=1600)
    {
        document.getElementById("teammembertitle").style.transform = "scale(1)";
    }
    else{
        document.getElementById("teammembertitle").style.transform = "scale(0)";
    }
    if(scrollTop>=1700)
    {
        document.getElementsByClassName("pic")[0].style.transform = "scale(1)";
    }
    else{
        document.getElementsByClassName("pic")[0].style.transform = "scale(0)";
    }

    // Testimonials
    if(scrollTop>=2100)
    {
        document.body.getElementsByClassName("Testimonials")[0].style.transform = "scale(1)";
    }
    else{
        document.getElementsByClassName("Testimonials")[0].style.transform = "scale(0)";
    }
    //价格区域
    if(scrollTop>=2900)
    {
        document.getElementById("pricetitle").style.transform = "translate(0)";

        document.getElementById("pricep").style.transform = "rotate(360deg)";
    }
    else{
        document.getElementById("pricep").style.transform = "rotate(0)";
        document.getElementById("pricetitle").style.transform = "translate(-1000px)";
    }

    if(scrollTop>=3000)
    {
        document.getElementById("pricelist").style.transform = "scale(1)";
    }
    else{
        document.getElementById("pricelist").style.transform = "scale(0)";
    }

    //棕色第二部分
    if(scrollTop>=3500){
        document.body.getElementsByClassName("middle2")[0].style.width = "100%";
    }
    else{
        document.body.getElementsByClassName("middle2")[0].style.width = "0";
    }
    //最新博客
    
    if(scrollTop>=4000)
    {
        document.getElementById("Info1").style.transform = "translate(0px)";

        document.getElementById("Info2").style.transform = "translate(0px)";

        document.getElementById("blogtitle").style.transform = "translate(0px)"

        document.getElementById("blogbutton").style.transform = "translate(0px)"
    }
    else{
        document.getElementById("Info1").style.transform = "translate(-1000px)";

        document.getElementById("Info2").style.transform = "translate(1000px)";

        document.getElementById("blogtitle").style.transform = "translate(0px,-1000px)"

        document.getElementById("blogbutton").style.transform = "translate(0px,1000px)"
    }
}
//点击展开搜索栏
var onput = 0;
function putsearch(){
    if(onput == 0)
    {
        onput = 1;

        document.getElementsByClassName("search")[0].style.backgroundImage = "url(./images/smallimg/cencel.png)";
        document.getElementsByClassName("search")[0].style.backgroundSize = "100% 100%";
        console.log("111");

        document.getElementById("navinput").style.transform = "scale(1)";
    }
    else{
        onput = 0;
        document.getElementsByClassName("search")[0].style.backgroundImage = "url(./images/search.png)";
        console.log("222");

        document.getElementById("navinput").style.transform = "scale(0)";
    }
}


//点击回到开头
function rolltotop(){
    window.scrollTo({top:0,
        behavior:"smooth"  
    });
    console.log("执行成功");
}

